<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<meta charset="UTF-8">
<html>
<head>
	<base href="<%=basePath%>">

	<title>编辑权限</title>

	<meta name="pragma" content="no-cache">
	<meta name="cache-control" content="no-cache">
	<meta name="expires" content="0">
	<link href="/static/easyui/themes/insdep/easyui.css" rel="stylesheet" type="text/css">
	<link href="/static/easyui/themes/insdep/easyui_animation.css" rel="stylesheet" type="text/css">
	<link href="/static/easyui/themes/insdep/easyui_plus.css" rel="stylesheet" type="text/css">
	<link href="/static/easyui/themes/insdep/insdep_theme_default.css" rel="stylesheet" type="text/css">
	<link href="/static/easyui/themes/insdep/icon.css" rel="stylesheet" type="text/css">
	<link href="/static/easyui/themes/color.css" rel="stylesheet" type="text/css">

	<link href="/static/ztree/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css">
	<link href="/static/css/common.css" rel="stylesheet" type="text/css">

	<script type="text/javascript" src="/static/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="/static/easyui/themes/insdep/jquery.insdep-extend.min.js"></script>
	<script type="text/javascript" src="/static/ztree/jquery.ztree.all.min.js"></script>
	<script type="text/javascript" src="/static/easyui/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="/static/kindeditor/kindeditor-all-min.js"></script>
</head>
<style type="text/css">
	.myselect {
		height: 30px;
	}
</style>

<body style="width:100%;max-width:100%;padding:10px 30px;">
<form id="form" method="post">
	<strong>主要信息</strong>
	<section class="info-section">

		<input type="hidden" name="id"  th:value="${leads.id}">
		<table id="tb">
			<tr>
				<td class="text-title">线索负责人</td>
				<td class="text-content">
					<select class="myselect" name="ownerUserId">
						<option th:each="user:${users}" th:selected="${user.id == leads.ownerUserId}? true:false "
								th:value="${user.id}" th:text="${user.username}"
						>请选择负责人</option>
					</select>
					<button value="放入线索池" id="fang" >放入线索池</button>
				</td>
				<td class="text-title">公司名称</td>
				<td class="text-content">
					<input type="text" name="name"  th:value="${leads.name}" class="easyui-textbox theme-textbox-radius" data-options="required:false">
				</td>
			</tr>
			<tr>
				<td class="text-title">来源</td>
				<td class="text-content">
					<select class="myselect" name="source">
						<option value="合作伙伴" th:selected="${leads.source == '合作伙伴'}?true:false">合作伙伴</option>
						<option value="广告" th:selected="${leads.source == '广告'}?true:false">广告</option>
						<option value="营销" th:selected="${leads.source == '营销'}?true:false">营销</option>
						<option value="朋友介绍" th:selected="${leads.source == '朋友介绍'}?true:false">朋友介绍</option>
					</select>
				</td>
				<td class="text-title">联系人姓名</td>
				<td class="text-content">
					<input type="text" name="contactsName" th:value="${leads.contactsName}" class="easyui-textbox theme-textbox-radius" data-options="required:false">
				</td>
			</tr>
			<tr>
				<td class="text-title">职位</td>
				<td class="text-content">
					<input type="text" name="position" th:value="${leads.position}" class="easyui-textbox theme-textbox-radius" data-options="required:false">
				</td>

				<td class="text-title">尊称</td>
				<td class="text-content">
					<select class="myselect" name="saltname">
						<option value="先生" th:selected="${leads.saltname == '先生'}?true:false">先生</option>
						<option value="女士" th:selected="${leads.saltname == '女士'}?true:false">女士</option>
					</select>
				</td>
			</tr>

			<tr>
				<td class="text-title">地址</td>
				<td class="text-content" colspan="3">
					<input type="text" style="width:550px;" th:value="${leads.address}" name="address" class="easyui-textbox theme-textbox-radius" data-options="required:false">
				</td>
			</tr>
			<tr>
				<td class="text-title">手机</td>
				<td class="text-content">
					<input type="text" name="mobile" th:value="${leads.mobile}" class="easyui-textbox theme-textbox-radius" data-options="required:false">
				</td>
				<td class="text-title">邮箱</td>
				<td class="text-content">
					<input type="text" name="email" th:value="${leads.email}" class="easyui-textbox theme-textbox-radius" data-options="required:false">
				</td>
			</tr>
			<tr>
				<td class="text-title">下次联系内容</td>
				<td class="text-content">
					<input type="text" name="nextstep" th:value="${leads.nextstep}" class="easyui-textbox theme-textbox-radius" data-options="required:true">
				</td>
				<td class="text-title">下次联系时间</td>
				<td class="text-content">
					<input class="easyui-datetimebox"  th:value="${leads.nextstepTime}" name="nextstepTime" data-options="required:false,showSeconds:false" style="width:150px">
				</td>
			</tr>


		</table>

	</section>
	<strong>附加信息</strong>
	<section class="info-section">
		<table>
			<tr>
				<td class="text-title">备注</td>
				<td class="text-content">
					<textarea name="leadnote" th:value="${leads.leadnote}" th:text="${leads.leadnote}" rows="5" style="width:80%;"></textarea>
				</td>
			</tr>
			<tr>
				<td colspan="2" style="text-align: center;margin-top: 10px;">
					<a  th:if="${leads.id != null}" href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton button-primary"
						style="margin-left:-70px;">保存</a>
					<a  th:if="${leads.id == null}" href="javascript:void(0);" id="addBtn" class="easyui-linkbutton button-primary"
						style="margin-left:-70px;">新建</a>
					<a href="javascript:void(0);" id="resetBtn" class="easyui-linkbutton button-danger"
					   style="margin-left:30px;">重置</a>
				</td>


			</tr>
		</table>
	</section>
</form>
<script src="/static/js/jquery.serializejson.min.js"></script>
<script type="text/javascript">
	$(function () {

		$(function () {
			//重置按钮
			$("#resetBtn").on("click", function (event) {
				$("#form").form("reset");
			});

			//修改
			$("#saveBtn").click(function (event) {
				event.preventDefault();
				$.ajax({
					type: "POST",
					url: '/EditLead',
					data: JSON.stringify($("#form").serializeJSON()),
					dataType: "json",
					contentType : "application/json",
					success: function (date) {
						if(date.d){
							alert(date.msg)
							parent.parent.$("#topWindow").window("close");
						}else {
							alert(date.msg)
						}

					}
				});
			})

			/*放入线索池*/
			$("#fang").click(function (event) {
				event.preventDefault();
				$.ajax({
					type: "POST",
					url: '/leads/fang',
					data: JSON.stringify($("#form").serializeJSON()),
					dataType: "json",
					contentType : "application/json",
					success: function (date) {
						if(date.d){
							alert(date.msg)
						}else {
							alert(date.msg)
						}

					}
				});
			})
		});
	});

</script>
</body>
</html>
